package com.huluobo.h3kotlinproject.category

import android.view.LayoutInflater
import android.view.ViewGroup
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.huluobo.h3kotlinproject.R
import com.huluobo.h3kotlinproject.data.GoodsBean
import com.huluobo.h3kotlinproject.databinding.ItemCategoryGoodsBinding

/**
 *  Created by LC on 2023/10/28.
 */
class CategoryGoodsAdapter(list: MutableList<GoodsBean>) :
    BaseQuickAdapter<GoodsBean, CategoryGoodsAdapter.CategoryGoodsViewHolder>(R.layout.item_category_goods, list) {

    class CategoryGoodsViewHolder(var itemDataBinding: ItemCategoryGoodsBinding) : BaseViewHolder(itemDataBinding.root)

    override fun convert(holder: CategoryGoodsViewHolder, item: GoodsBean) {
        holder.itemDataBinding.goods = item
    }

    override fun createBaseViewHolder(parent: ViewGroup, layoutResId: Int): CategoryGoodsViewHolder {
        val itemDataBinding = ItemCategoryGoodsBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return CategoryGoodsViewHolder(itemDataBinding)
    }
}